<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

	<ui:composition template="/faces/manager/xhtml/templates/template.xhtml">
		<ui:define name="manager-content">
			<table id="manager-content-panel" cellpadding="0" cellspacing="1">
				<tr>
					<td id="manager-content-header">
						<h:form>
							<p:breadCrumb style="width:810px;">
								<p:menuitem value="#{msg['manager.menu.navigator.home']}"/>
								<p:menuitem ajax="false" value="#{msg['manager.menu.navigator.admin']}" action="/faces/manager/xhtml/main.xhtml" />
								<p:menuitem ajax="false" value="#{msg['manager.menu.navigator.cliente']}" action="/faces/manager/xhtml/cliente/list.xhtml" />
								<p:menuitem value="#{msg['manager.menu.navigator.cliente.update']}" />
							</p:breadCrumb>			
						</h:form>
					</td>
				</tr>
				<tr>
					<td id="manager-content-body">
						<h:form>	
							<p:fieldset legend="#{msg['manager.menu.left.admin.cliente.title']}" styleClass="manager-fieldset-content"> 									
								<p:spacer height="20px" />
								<p:panel>
									<p:outputPanel id="proprietario-list">
										<table cellpadding="0" cellspacing="0">	
											<tr>
												<td class="form-column-label">
													<h:outputText value="#{msg['manager.anuncio.create.status']}" />:											
												</td>
												<td class="form-column-value">
													<h:selectBooleanCheckbox value="#{clienteController.cliente.ativo}" />
												</td>
												<td class="form-column-error"></td>
											</tr>														
											<tr>
												<td class="form-column-label">
													<h:outputText value="#{msg['manager.cliente.create.tipoPessoa']}" />:
												</td>
												<td class="form-column-value">
													<h:selectOneMenu id="slc_cliente" styleClass="selectOneMenuForm" value="#{clienteController.tipoPessoa}" disabled="true">
							               				<f:selectItems value="#{clienteController.tiposPessoa}" var="pessoa" itemLabel="#{pessoa}" itemValue="#{pessoa.value}"/>
							               				<f:ajax event="change" execute="@this" render="dados-pessoais" />
							               			</h:selectOneMenu>
												</td>
												<td class="form-column-error"></td>										
											</tr>
											<tr>
												<td class="form-column-label">
													<h:outputText value="#{msg['manager.cliente.create.tipoCliente']}" />
												</td>
												<td class="form-column-value">
													<h:selectOneMenu id="slc_tipo_cliente" styleClass="selectOneMenuForm" value="#{clienteController.tipoCliente}" disabled="true">
														<f:selectItems value="#{clienteController.tipoClientes}"/>
														<f:ajax event="change" execute="@this" render="proprietario-list" />
													</h:selectOneMenu>
												</td>
												<td class="form-column-error"></td>
											</tr>	
											<tr>
												<td class="form-column-label">
													<h:outputText value="#{msg['manager.cliente.create.template']}" />
												</td>
												<td class="form-column-value">
													<h:selectBooleanCheckbox value="#{clienteController.cliente.paginaPessoal}">
														<f:ajax event="change" execute="@this" render="template control-buttons"  />
													</h:selectBooleanCheckbox>
												</td>
												<td class="form-column-error"></td>
											</tr>	
											<tr>
												<td class="form-column-label">
													<h:outputText value="#{msg['manager.cliente.create.plano']}" />
												</td>
												<td class="form-column-value">
													<h:selectOneMenu id="slc_plano" styleClass="selectOneMenuForm" value="#{clienteController.cliente.plano}">		               		
								               			<f:selectItems value="#{clienteController.planosAssinatura}"/>     		
						            				</h:selectOneMenu>
												</td>
												<td class="form-column-error"></td>
											</tr>									
											<p:outputPanel rendered="#{clienteController.tipoCliente == 'R'}">
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.representante.proprietario']}" />
													</td>
													<td class="form-column-value">
														<h:selectOneMenu id="slc_proprietario" styleClass="selectOneMenuForm" value="#{clienteController.proprietario.id}">
															<f:selectItems value="#{clienteController.proprietarios}" var="proprietario" itemLabel="#{proprietario.pessoa.nome}" itemValue="#{proprietario.id}" />
														</h:selectOneMenu>
													</td>
													<td class="form-column-error"></td>
												</tr>												
											</p:outputPanel>
											<tr>
												<td class="form-column-label">
													<h:outputText value="#{msg['manager.cliente.create.representante.creci']}" />
												</td>
												<td class="form-column-value">
													<p:inputText id="creci" name="creci" value="#{clienteController.cliente.CRECI}" styleClass="inputText" />
												</td>
												<td class="form-column-error"></td>
											</tr>																																																																			
										</table>
									</p:outputPanel>
								</p:panel>		
								<p:spacer height="5px" />
								<p:outputPanel id="template">
									<p:outputPanel id="complex-template" rendered="#{clienteController.cliente.paginaPessoal}">
										<p:panel>
											<table cellpadding="0" cellspacing="0">
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFundo']}" />	
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFundo}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corBarra']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corBarra}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corBarraMenu']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corBarraMenu}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>	
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFontes']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFontes}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>				
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFundoMenuBusca']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFundoMenuBusca}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFundoRodape']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFundoRodape}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFundoLogo']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFundoLogo}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFundoLancamento']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFundoLancamento}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>		
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.corFundoDestaque']}"/>
													</td>
													<td class="form-column-value">
														<p:colorPicker value="#{clienteController.cliente.template.corFundoDestaque}" converter="#{colorConverter}"/>
													</td>
													<td class="form-column_error"></td>
												</tr>											
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.cliente.create.url']}" />
													</td>
													<td class="form-column-value">
														<p:inputText id="url" value="#{clienteController.cliente.template.url}" styleClass="inputText"/>
														<p:watermark for="url" value="#{msg['manager.cliente.create.watermark']}"/>
													</td>
													<td  class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.quemsomos']}" /> </td>
													<td class="form-column-value">
														<p:inputTextarea id="descricao" value="#{clienteController.cliente.template.quemSomos}" styleClass="inputTextArea" 
															required="false" maxHeight="120" />
													</td>
													<td class="form-column-error"></td>
												</tr>																				
											</table>
										</p:panel>
									</p:outputPanel>									
								</p:outputPanel>						
								<p:spacer height="5px" />
								<p:outputPanel id="dados-pessoais">
									<p:outputPanel id="pessoa-fisica" rendered="#{clienteController.tipoPessoa == 'F'}">
										<p:focus for="nome-pf" />
										<p:panel>
											<table cellpadding="0" cellspacing="0">
												<tr>
													<td class="form-column-label">
														<h:outputText value="#{msg['manager.servico.create.status']}" />:											
													</td>
													<td class="form-column-value">
														<h:selectBooleanCheckbox value="#{clienteController.cliente.ativo}" />
													</td>
													<td class="form-column-error"></td>
												</tr>		
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.pf.nome']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="nome-pf" styleClass="inputText" value="#{clienteController.pessoaFisica.nome}" 
							              					required="true" label="#{msg['manager.cliente.create.pf.nome']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"><p:message for="nome-pf" /></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.pf.cpf']}" />:</td>
													<td class="form-column-value">
														<p:inputMask id="cpf" styleClass="inputText" value="#{clienteController.pessoaFisica.cpf}" 
							              					required="true" label="#{msg['manager.cliente.create.pf.cpf']}" mask="999.999.999-99">
							              				</p:inputMask>
							              				<p:watermark for="cpf" value="555.555.555-55"/>
													</td>
													<td class="form-column-error"><p:message for="cpf" /></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.pf.rg']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="rg" styleClass="inputText" value="#{clienteController.pessoaFisica.rg}" 
							              					required="true" label="#{msg['manager.cliente.create.pf.rg']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"><p:message for="rg" /></td>
												</tr>									
											</table>								
										</p:panel>
									</p:outputPanel>
									<p:outputPanel id="pessoa-juridica" rendered="#{clienteController.tipoPessoa == 'J'}">
										<p:focus for="nome-pj" />
										<p:panel>
											<table cellpadding="0" cellspacing="0">
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.pj.nome']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="nome-pj" styleClass="inputText" value="#{clienteController.pessoaJuridica.nome}" 
							              					required="true" label="#{msg['manager.cliente.create.pj.nome']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"><p:message for="nome-pj" /></td>											
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.pj.cnpj']}" />:</td>
													<td class="form-column-value">
														<p:inputMask id="cnpj" styleClass="inputText" value="#{clienteController.pessoaJuridica.cnpj}" 
							              					required="true" label="#{msg['manager.cliente.create.pj.cnpj']}" mask="99.999.999/9999-99">
							              				</p:inputMask> 
							              				<p:watermark for="cnpj" value="55.555.555/5555-55"/>
													</td>
													<td class="form-column-error"><p:message for="cnpj" /></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.pj.razaoSocial']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="razao-social" styleClass="inputText" value="#{clienteController.pessoaJuridica.razaoSocial}" 
							              					required="true" label="#{msg['manager.cliente.create.pj.razaoSocial']}">
							              				</p:inputText> 
													</td>
													<td class="form-column-error"><p:message for="razao-social" /></td>
												</tr>											
											</table>
										</p:panel>																		
									</p:outputPanel>
									<p:spacer height="5px" />
									<p:outputPanel id="contato">
										<p:panel>
											<table cellpadding="0" cellspacing="0">
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.contato.site']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="site" styleClass="inputText" value="#{clienteController.cliente.site}" 
							              					required="false" label="#{msg['manager.cliente.create.contato.site']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.contato.email']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="email" styleClass="inputText" value="#{clienteController.cliente.email}" 
							              					required="true" label="#{msg['manager.cliente.create.contato.email']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"><p:message for="email"/></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.contato.msn']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="msn" styleClass="inputText" value="#{clienteController.cliente.msn}" 
							              					required="false" label="#{msg['manager.cliente.create.contato.msn']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.telefone.celular']}" />:</td>
													<td class="form-column-value">
														<p:inputMask id="celular" styleClass="inputText" value="#{clienteController.cliente.telefoneCelular}" 
							              					required="false" label="#{msg['manager.cliente.create.telefone.celular']}" mask="(99)9999-9999">
							              				</p:inputMask>
							              				<p:watermark for="celular" value="(55)5555-5555"/>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.telefone.fixo']}" />:</td>
													<td class="form-column-value">
														<p:inputMask id="fixo" styleClass="inputText" value="#{clienteController.cliente.telefoneFixo}" 
							              					required="false" label="#{msg['manager.cliente.create.telefone.fixo']}" mask="(99)9999-9999">
							              				</p:inputMask>
							              				<p:watermark for="fixo" value="(55)5555-5555"/>
													</td>
													<td class="form-column-error"></td>
												</tr>												
											</table>
										</p:panel>										
									</p:outputPanel>
									<p:spacer height="5px"/>
									<p:outputPanel id="endereco">
										<p:panel>
											<table cellpadding="0" cellspacing="0">
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.endereco.cep']}" />:</td>
													<td class="form-column-value">
														<p:inputMask id="cep" styleClass="inputText" value="#{clienteController.cliente.endereco.cep}" 
							              					required="false" label="#{msg['manager.cliente.create.endereco.cep']}" mask="99999-999">
							              				</p:inputMask>
							              				<p:watermark for="cep" value="55555-555"/>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.endereco.rua']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="rua" styleClass="inputText" value="#{clienteController.cliente.endereco.rua}" 
							              					required="false" label="#{msg['manager.cliente.create.endereco.rua']}">
							              				</p:inputText>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.endereco.numero']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="numero" styleClass="inputText" value="#{clienteController.cliente.endereco.numero}" 
							              					required="false" label="#{msg['manager.cliente.create.endereco.numero']}" maxlength="4" >
							              				</p:inputText>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['manager.cliente.create.endereco.bairro']}" />:</td>
													<td class="form-column-value">
														<p:inputText id="bairro" styleClass="inputText" value="#{clienteController.cliente.endereco.bairro}" 
							              					required="false" label="#{msg['manager.cliente.create.endereco.bairro']}" >
							              				</p:inputText>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText  value="#{msg['manager.cliente.create.endereco.estado']}" />:</td>
													<td class="form-column-value">
														<h:selectOneMenu id="estado" value="#{clienteController.estado}"  styleClass="selectOneMenuForm" converter="#{simpleEntityConverter}">		               		
										               		<f:selectItems value="#{clienteController.estados}" var="estado" itemLabel="#{estado.nome}" itemValue="#{estado}" />
										               		<f:ajax listener="#{clienteController.reloadMunicipios}" event="change" execute="@this" render="municipio" />       		
										            	</h:selectOneMenu>
													</td>
													<td class="form-column-error"></td>
												</tr>
												<tr>
													<td class="form-column-label"><h:outputText value="#{msg['body.searchpanel.cidade']}" />:</td>
													<td class="form-column-value">
														<h:selectOneMenu id="municipio" styleClass="selectOneMenuForm" value="#{clienteController.cliente.endereco.municipio.id}">
										               		<f:selectItems value="#{clienteController.municipios}" var="municipio" itemLabel="#{municipio.nome}" itemValue="#{municipio.id}" />
										               </h:selectOneMenu>
													</td>
													<td class="form-column-error"></td>
												</tr>
												
											</table>
										</p:panel>									
									</p:outputPanel>																		
								</p:outputPanel>
								<p:spacer height="20px" />
								<p:outputPanel id="control-buttons">
									<table id="panel-buttons" cellpadding="0" cellspacing="0">
										<tr>
											<td>
												<p:commandButton value="#{msg['manager.cliente.button.save']}" 
													action="#{clienteController.update}" ajax="false" icon="save-button"></p:commandButton>
												<p:spacer width="10px" />
												<p:commandButton value="#{msg['manager.cliente.button.attach']}" ajax="true" icon="attach-button" 
													oncomplete="clienteDialog.show()" disabled="#{!clienteController.cliente.paginaPessoal}"/>
											</td>
										</tr>
									</table>
								</p:outputPanel>
								<p:spacer height="5px" />
							</p:fieldset>
						</h:form>
					</td>
				</tr>
			</table>
			<p:dialog header="#{msg['manager.cliente.create.anexo.imagens']}" widgetVar="clienteDialog" resizable="false"  
              width="600" height="400" modal="true">  
  				<h:form id="form-image" enctype="multipart/form-data" prependId="false">		  				
  					<table class="photo-panel-upload" cellpadding="0" cellspacing="0">
  						<tr>
  							<td><p:messages id="msg-error" showDetail="true"/></td>
  						</tr>
  						<tr>
  							<td>
  								<p:panel>
  									 <p:fileUpload fileUploadListener="#{clienteController.handleFileUpload}"  
							            mode="advanced"   
							            update=":form-image:media-list :form-image:msg-error"
							            sizeLimit="2097152"
							            label="${msg['manager.cliente.button.upload.browse']}"
							            allowTypes="/(\.|\/)(gif|jpe?g|png|swf)$/"/>   									
		              			</p:panel>					
  							</td>
  						</tr>
  					</table>
  					<p:spacer height="5px"/>
					<p:outputPanel id="media-list">	
						<p:dataTable var="media" value="#{clienteController.mediasAtivo}">        	 					   	 								        	 					
       	 					
       	 					<p:column headerText="#{msg['manager.cliente.button.media.tipo']}">	          	 						
					            <h:outputText value="#{msg['manager.cliente.button.media.logo']}" rendered="#{media.imageType == 'logo'}"/>
					            <h:outputText value="#{msg['manager.cliente.button.media.banner']}" rendered="#{media.imageType == 'banner'}"/>
					            <h:outputText value="#{msg['manager.cliente.button.media.corretor']}" rendered="#{media.imageType == 'corretor'}"/>  					              					
       	 					</p:column>
       	 					
       	 					<p:column headerText="#{msg['manager.cliente.button.upload.browse']}" >		        	 						
       	 						<h:outputText value="#{media.nome}"/>
       	 					</p:column>
       	 					
       	 					<p:column >		        	 					
       	 						<p:commandLink update=":form-image:media-list" actionListener="#{clienteController.removeMediaFile}" ajax="true" rendered="#{media.imageType == 'logo'}">
       	 							<f:param name="mediaType" value="logo"/>
       	 							<h:graphicImage value="#{resource['images:icons/16x16/delete.png']}" />
       	 						</p:commandLink>
       	 						<p:commandLink update=":form-image:media-list" actionListener="#{clienteController.removeMediaFile}" ajax="true" rendered="#{media.imageType == 'corretor'}">
       	 							<f:param name="mediaType" value="corretor" />
       	 							<h:graphicImage value="#{resource['images:icons/16x16/delete.png']}" />
       	 						</p:commandLink>
       	 						<p:commandLink update=":form-image:media-list" actionListener="#{clienteController.removeMediaFile}" ajax="true" rendered="#{media.imageType == 'banner'}">
       	 							<f:param name="mediaType" value="banner" />
       	 							<h:graphicImage value="#{resource['images:icons/16x16/delete.png']}" />
       	 						</p:commandLink>
       	 					</p:column>    
       	 					       	 												      	 					        	 					
       	 				</p:dataTable>					
             		</p:outputPanel>		        			              		              		          		
             	</h:form>
  			</p:dialog>		
		</ui:define>
	</ui:composition>
</html>